home *** CD-ROM | disk | FTP | other *** search
- /*
- File: UniversalModule.h
-
- Contains: Header file for universal module
-
- Version: xxx put version here xxx
-
- Copyright: © 1997-1998 by Apple Computer, Inc., all rights reserved.
-
- */
- #ifndef __UniversalModuleH__
- #define __UniversalModuleH__
-
- #include <Types.h>
- #include <Devices.h>
- #include <DriverServices.h>
- #include <USB.h>
-
- // this is the prototype for all HIDModules that follow the UHID spec
- #include "UniversalHIDModule.h"
-
- Boolean immediateError(OSStatus err);
- void UniversalModuleInitiateTransaction(USBPB *pb);
- void UniversalModuleDelayCompletionProc(USBPB *pb);
- void TransactionCompletionProc(USBPB *pb);
- void DriverEntry(USBDeviceRef device, USBDeviceDescriptorPtr pDeviceDescriptor);
- void InterfaceEntry(UInt32 interfaceNum, USBInterfaceDescriptorPtr pInterfaceDescriptor, USBDeviceDescriptorPtr pDeviceDescriptor, USBInterfaceRef interfaceRef);
- void InterfaceExit(USBInterfaceRef interfaceRef, USBInterfaceDescriptorPtr pInterfaceDescriptor);
-
- /* Prototypes from UniversalModuleHeader.c Tue, Mar 17, 1998 3:30:22 PM */
- static OSStatus UniversalModuleInitialize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
- static OSStatus UniversalInterfaceInitialize(UInt32 interfaceNum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBInterfaceRef interfaceRef);
- static OSStatus UniversalModuleFinalize(USBDeviceRef theDeviceRef, USBDeviceDescriptorPtr pDesc);
-
- /* Prototypes from UniversalConfigParse.c Tue, Mar 17, 1998 3:17:14 PM */
- OSErr FindHIDInterfaceByInterfaceNumber(LogicalAddress pConfigDesc, UInt32 interfaceNumber, USBInterfaceDescriptorPtr * hInterfaceDesc);
- OSErr GetHIDDescriptors(USBConfigurationDescriptorPtr pConfigDesc, USBHIDDescriptorPtr * hHIDDesc);
-
- /* Prototypes from UniversalHIDAPI.c */
- void NotifyRegisteredHIDUser(UInt8 hidReport[]);
- void DeferredNotifyRegisteredHIDUser(void * unused);
-
- #define kUniversalRetryCount 10
- #define kDeferredHIDReportRingBufferSize 8
- #define kMaxHIDReportSize 64 // 8 bytes for low speed, but 64 bytes for high speed
-
- enum driverstages
- {
- kUndefined = 0,
- kGetHIDDesc,
- kAllocHIDOwnedDescMem,
- kGet1OwnedHIDDesc,
- kConfigureInterface,
- kFindInterruptPipe,
- kReadInterruptPipe,
- kDriverStagesMask = 0x0fff,
- kReturnFromDriver = 0x1000,
- kRetryTransaction = 0x2000,
- kSyncTransaction = 0x4000,
- kCompletionPending = 0x8000
- };
-
- typedef union
- {
- USBHIDDescriptor d;
- UInt8 storage[256];
- } usbMaxHIDDescriptor;
-
-
-
- typedef struct
- {
- UInt32 type; // 8 bits significant
- UInt32 length; // 16 bits significant
- UInt8 * descriptor; // pointer to the descriptor
- UInt32 typeIndex; // this is the ith item of this type
- } usbHIDDescriptorInfo;
-
- typedef struct
- {
- USBPB pb; // this _must_ come first in the structure!
- void (*handler)(USBPB *pb);
-
- UInt32 interfaceNum;
- USBInterfaceRef interfaceRef;
- USBPipeRef pipeRef;
-
- UInt32 numPipes;
-
- USBDeviceDescriptor deviceDescriptor;
- USBInterfaceDescriptor interfaceDescriptor;
- usbMaxHIDDescriptor hidDiscriptor;
- usbHIDDescriptorInfo * hidOwnedDiscriptors;
- UInt32 hidOwnedDescriptorsCount;
- UInt32 allocatedBufferSize;
-
- UInt32 maxPacketSize;
- UInt8 hidReport[kMaxHIDReportSize];
-
- UInt8 deferredHIDReports[kMaxHIDReportSize * kDeferredHIDReportRingBufferSize];
- UInt32 deferredHIDRing_Head;
- UInt32 deferredHIDRing_Tail;
-
- UHIDInterruptProcPtr pClientInterruptRoutine;
- UInt32 clientRefCon;
-
- SInt32 retryCount;
- SInt32 transDepth;
-
- } usbUniversalPBStruct;
-
- #endif //__UniversalModuleH__
-